package com.example.expresscheck.adapter;


import com.example.expresscheck.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class AdapterSelectCompany extends BaseAdapter {
	private Context context;
	String[] companyLogos;
	String[] companyCodes;
	String[] companyNames;

	public AdapterSelectCompany(Context context) {
		this.context = context;
		companyCodes = context.getResources().getStringArray(
				R.array.company_code);
		companyNames = context.getResources().getStringArray(
				R.array.company_name);
		companyLogos = context.getResources().getStringArray(
				R.array.company_logo);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return companyNames.length;
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public View getView(int index, View arg1, ViewGroup arg2) {
			View itemView = LayoutInflater.from(context).inflate(R.layout.item_select_company, null);
	        TextView company_name = (TextView) itemView.findViewById(R.id.tv_item_company_name);
	        TextView company_code = (TextView) itemView.findViewById(R.id.tv_item_company_code);
	        ImageView company_logon = (ImageView) itemView.findViewById(R.id.iv_item_logo);
	        company_code.setText(companyCodes[index]);
	        company_name.setText(companyNames[index]);
	        company_logon.setBackgroundResource(context.getResources().getIdentifier("com.example.expresscheck:drawable/"+companyLogos[index], null, null));  
        return itemView;
	}

}
